module.exports = (url) => {
  return new Promise((resolve, reject) => {
    wx.downloadFile({
      url,
      success: res => {
        if (res.statusCode === 200) {
          resolve(res.tempFilePath)
        } else {
          wx.showModal({
            content: '服务出错，请稍后重试',
            showCancel: false,
          })
          reject(res)
        }
      },
      fail: err => {
        wx.showModal({
          content: '服务出错，请稍后重试',
          showCancel: false,
        })
        reject(err)
      }
    })
  })
}